package com.example.closerest;
 
//import com.example.android.R;
 
import android.content.Context;
//import android.media.Image;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
 
public class MobileArrayAdapter extends ArrayAdapter<String> {
	private final Context context;
	private final String[] values;
	private final String[] values1;
	private final String[] values2;
	private final String[] values3;
 
	public MobileArrayAdapter(Context context, String[] values, String[] values1, String[] values2, String[] values3) {
		super(context, R.layout.activity_cafe, values);
		this.context = context;
		this.values = values;
		this.values1 = values1;
		this.values2 = values2;
		this.values3 = values3;
	}
 
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context
			.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
		View rowView = inflater.inflate(R.layout.activity_cafe, parent, false);
		TextView textView = (TextView) rowView.findViewById(R.id.label);
		ImageView imageView = (ImageView) rowView.findViewById(R.id.logo);
		String a="Name:"+values[position]+"\nTelephone no.:"+values1[position]+"\nAddress:"+values2[position];
		textView.setText(a);
		//textView.
		//textView.setText(values1[position]);
 
		// Change icon based on name
		String s = values[position];
 
		System.out.println(s);
		if (s.equals("Test Kitchen 1")) {
			imageView.setImageResource(R.drawable.testkitchen);
		} else if (s.equals("McDonald")) {
			imageView.setImageResource(R.drawable.mcdonalds);
		} else if (s.equals("Si Sun Fast Food")) {
			imageView.setImageResource(R.drawable.timenew);
		} else {
			imageView.setImageResource(R.drawable.mcdonalds);
		}
 
		return rowView;
	}
	

}